Skip to content

Support Arduino-style labeled multi-value plotter data#487

Open
makermelissa-piclaw wants to merge 2 commits intocircuitpython:betafrom
makermelissa-piclaw:fix/issue-457-multi-value-labeled-plotter-data
Open

Support Arduino-style labeled multi-value plotter data#487
makermelissa-piclaw wants to merge 2 commits intocircuitpython:betafrom
makermelissa-piclaw:fix/issue-457-multi-value-labeled-plotter-data

Conversation

@makermelissa-piclaw
Copy link
Copy Markdown
Contributor

Fixes #457.

The Arduino IDE Serial Plotter accepts a label:value format with
tab/comma/space separators (and supports many series at once). The
web-editor plotter previously only understood plain CSV / tuple /
list lines, so a sketch that prints Temp:23.4\tHum:55.1 would
either drop the line or only plot the digits it could pull from the
front of the token.

This PR teaches plotValues the labeled format:

  • New parseLabeledValues helper splits on ,, \t, or runs of
    whitespace, then peels off an optional label: prefix per token.
  • Datasets are now tracked by label when one is provided, so series
    stay on the same line across frames even if the sketch reorders
    them (or omits some on a given frame). Unlabeled lines keep the
    existing positional behavior, so old CSV / tuple / list sketches
    are unaffected.
  • When a labeled series doesn't appear on a given frame, that
    dataset is padded with null so the x-axis stays aligned.
  • Chart legend is enabled so the labels actually show up.
  • Default color palette expanded from 3 to 16 distinct colors and
    reused round-robin, so multi-channel sketches (e.g. the AS7343
    spectral example referenced in the issue) don't all collapse to
    black after the fourth series.

Manual test cases

I unit-tested the parser against the following inputs (all parse to
the expected {label, value} pairs):

  • 1,2,3
  • 1\t2\t3
  • 1 2 3
  • Temp:23.4,Hum:55.1
  • 405nm_F1:123\t425nm_F2:456\tClear:789
  • A:1\tB:-2.5\tC:3e2
  • 1,Temp:42,3 (mixed labeled + positional)
  • A:1\tB:2\t (trailing tab)

Existing tuple (1,2,3) and list [1,2,3] paths are unchanged.

npm run build passes locally.

Match the Arduino IDE Serial Plotter input format so sketches that
print 'label:value' pairs separated by tabs (or commas/spaces) are
plotted with the labels shown in the legend instead of confusing the
parser. Each labeled series is tracked by name across frames so the
order can vary, and a per-frame padding pass keeps the x-axis aligned
when not every series reports on every line.

Existing tuple, list, and plain CSV formats continue to work
unchanged. The default color palette is also expanded from 3 colors
to 16 so plots with many series remain legible.

Fixes circuitpython#457
@makermelissa-piclaw makermelissa-piclaw changed the base branch from main to beta May 5, 2026 19:45
- Drop pale tints, gray, and brown from palette since they wash out on
  the dark theme's #777 plotter background.
- Pull legend label color from --terminal-text-color so it contrasts
  with the active theme instead of being hardcoded black.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-value labeled plotter data

1 participant